#include "ObPlayer.h"
#include "D3DApp.h"
#include "D3DInput.h"
#include "Collision.h"
#include "ObEnemies.h"
#include "ObStatic.h"
#include "ObMushRoomEdible.h"
#include "ObFlowerEdible.h"
#include "ObStarEdible.h"
#include "Camera.h"
#include "ETurtle.h"
#include "MapScene.h"
#include "ObBullet.h"
#include "ObPlant.h"
#include "cmath"
#include "ObDeathField.h"
#include "ObScoreTree.h"

IDirect3DTexture9* ObPlayer::mTex		= 0;
IDirect3DTexture9* ObPlayer::mBulletTex = 0;
CSound* ObPlayer::sDye			= 0;
CSound* ObPlayer::sShoot		= 0;
CSound* ObPlayer::sGetCoin		= 0;
CSound* ObPlayer::sExtraLife	= 0;
CSound* ObPlayer::sFinishMap	= 0;
CSound* ObPlayer::sJump			= 0;
CSound* ObPlayer::sLVUp			= 0;

float ObPlayer::PLAYER_NORMAL_SPD = 600.0f;
float ObPlayer::PLAYER_FAST_SPD = 800.0f;
float ObPlayer::PLAYER_JUMP_SPD = 300.0f;
float ObPlayer::PLAYER_NORMAL_X_ACCEL = 300.0f;
float ObPlayer::PLAYER_FAST_X_ACCEL = 500.0f;

ObPlayer::ObPlayer(){
	setId(MARIO);
	mRightFaced = RIGHT;
	setStatus(SMALL);
	
}

ObPlayer::ObPlayer(int nid, int ninfo){
	setId(nid);
	setInfo(ninfo);
}

ObPlayer::~ObPlayer(){

}

bool ObPlayer::setId(int nid){
	if(checkType(nid)){
		mID				= nid;
		mInfo			= RIGHT;

		mLife			= 3;
		mScore			= 0;

		mWidth			= 16.0f;
		mHeight			= 16.0f;
		mCenter			= D3DXVECTOR3(mWidth/2, mHeight/2, 0.0f);
		MAX_VELOCITYX	= PLAYER_NORMAL_SPD;
		MAX_VELOCITYY	= 0.0f;
		mIsYGravity		= true;
		mIsXGravity		= true;
		mCurrentSprite	= 0;
		mCurrentAction	= DONOTHING;
		mRightFaced		= RIGHT;	

		isJustHitted	= 0.0f;
		isGoD			= 0.0f;
		isJustAte		= 0.0f;

		canInput		= true;
		isBack			= false;
		count			= 0.0f;
		delaycount		= 0.0f;
		delayupdate		= 0.0f;
		jumpcount		= 0.0f;
		shootcount		= 0.0f;
		requestedKey	= 0;
		canRun			= true;
		mFakeStatus = SMALL;


		transportindelay	= 0.0f;
		transportoutdelay	= 0.0f;
		transforttox	= 0.0f;
		transforttoy	= 0.0f;
		transfortvel	= D3DXVECTOR3(0.0f,0.0f,0.0f);

		isMapDone = false;
		highPos = 0;
		farpos = 0;
		return true;
	}else{
		return false;
	}
}

bool ObPlayer::setInfo(int ninfo){
	if(checkInfo(ninfo)){
		mInfo = ninfo;
		if(mInfo!=0){
			int temp = mInfo;
			int lenght = 1;
			while(temp>9){ lenght++; temp/=10; }

			if(lenght == 1){
				if(ninfo == LEFT){
					mRightFaced = LEFT;
				}else{
					mRightFaced = RIGHT;
				}
			}

			//save stat = [IsRightFace][PLAYERSTATUS][LIFE][Score]
			if(lenght>=4){//1230
				int statinfo = mInfo/(int)std::pow(10,(lenght - 3)); //123
				int tempIsRight = statinfo/100; //1
				if(tempIsRight == LEFT){
					mRightFaced = LEFT;
				}else{
					mRightFaced = RIGHT;
				}

				int conlai = statinfo%100; //23
				int tempstatus = conlai/10; //2
				switch (tempstatus)
				{
				case 1:
					setStatus(SMALL);
					break;
				case 2:
					setStatus(BIG);
					break;
				case 3:
					setStatus(FLOWER);
					break;
				default:
					setStatus(SMALL);
					break;
				}
				int mLife = conlai%10; //3
				int mScore = mInfo%(int)(statinfo*std::pow(10,(lenght - 3)));
			}
		}
		return true;
	}else{
		return false;
	}
}

bool ObPlayer::checkType(int nid){
	if(nid == MARIO){
		return true;
	}else{
		return false;
	}
}

bool ObPlayer::checkInfo(int ninfo){
	return true;
}

bool ObPlayer::getCanInput(){
	return canInput;
}
void ObPlayer::setCanInput(bool input){
	canInput = input;
}

void ObPlayer::kill(bool permakill){
	if(getIsGoD()) return;
	if(permakill) 
	{
		mCurrentAction = DIE;
		PlaySound(sDye);
		return;
	}

	switch (mStatus)
	{
	case SMALL:
		mCurrentAction = DIE;
		PlaySound(sDye);
		break;
	case BIG:
		setStatus(SMALL);
		isJustHitted = 2.0f;
		break;
	case FLOWER:
		setStatus(BIG);
		isJustHitted = 2.0f;
		break;
	default:
		mCurrentAction = DIE;
		PlaySound(sDye);
		break;
	}
}

void ObPlayer::transportByPile(float posx, float posy, float delay, D3DXVECTOR3 delayVelIn, D3DXVECTOR3 delayVelOut){
	setCanInput(false);
	mNeedCollision	= false;
	mIsYGravity		= false;
	mIsXGravity		= false;
	mVelocity = delayVelIn;

	transportindelay = 1.0f;
	transforttox = posx;
	transforttoy = posy;
	transfortvel = delayVelOut;	
}

void ObPlayer::getOutOfPile(){
	mPos.x	= transforttox;
	mPos.y	= transforttoy;
	mVelocity = transfortvel;
	transportoutdelay = 1.0f;
}

void ObPlayer::collidedWith(ObObject* object, CollisionRS rs){

	if(ObStatic* staticob = dynamic_cast<ObStatic*> (object)){

		if(isMapDone){
			mRightFaced = RIGHT;
			mVelocity.y = 0.0f;
			mIsYGravity = true;
			mVelocity.x = 50.0f;
			mCurrentAction = RUN;
		}

		if(staticob->getId() == ObDeathField::Deathfield1){
			kill(true);
			return;
		}

		if(ObPlant* plant = dynamic_cast<ObPlant*> (object)){
			kill(false);
			return;
		}

		if(staticob->getId() == ObCoin::SCORECOIN){
			mScore+=20;
			PlaySound(sGetCoin);
			return;
		}

		if(staticob->getId() == ObScoreTree::FLAGTREE){
			mVelocity.x = 0;
			mPos.x+=16.0f;
			mRightFaced = LEFT;
			mVelocity.y = -60.0f;
			mIsYGravity = false;
			mIsXGravity = false;
			isMapDone = true;
			canInput = false;
			highPos =(int) mPos.y;
			farpos =(int) mPos.x;
			mCurrentAction = JUMP;
			if(ObScoreTree* tree = dynamic_cast<ObScoreTree*> (object)){
				mScore+= (mPos.y - (tree->getPos().y - 80))*10;
			}
			return;
		}

		if(rs.mState == Bottom){
			mIsJump = false;
			jumpcount = 0.0f;
			mVelocity.y = 0.0f;
			mCurrentAction = RUN;
		}

		if(rs.mState == Top){
			mVelocity.y = 0.0f;
			jumpcount = 0.3f;
			mIsJump = true;
		}

		if(rs.mState == Left){
			requestedKey = DIK_LEFTARROW;
			canRun = false;
			mVelocity.x = 0.0f;
			mAcceleration.x = 0.0f;
			if(mIsJump){

			}
		}

		if(rs.mState == Right){
			requestedKey = DIK_RIGHTARROW;
			canRun = false;
			mAcceleration.x = 0.0f;
			mVelocity.x = 0.0f;
		}
		
		return;
	}

	if(ObMushroomEdible* staticob = dynamic_cast<ObMushroomEdible*> (object)){
		if(staticob->IsLVup){
			setLife(getLife() +1);
			PlaySound(sExtraLife);
		}else{
			if(mStatus == SMALL){
				setStatus(BIG);
				setStatus(BIG, true);
				isJustAte = 1.0f;
			}
			PlaySound(sLVUp);
		}
		
		return;
	}

	if(ObFlowerEdible* staticob = dynamic_cast<ObFlowerEdible*> (object)){
		if(mStatus == SMALL || mStatus == BIG){
			setStatus(FLOWER);
			setStatus(BIG, true);
			isJustAte = 1.0f;
		}
		PlaySound(sLVUp);
		return;
	}

	if(ObStarEdible* staticob = dynamic_cast<ObStarEdible*> (object)){
		isGoD = 8.0f;
	}

	if(ObBullet* staticob = dynamic_cast<ObBullet*> (object)){

		return;
	}

	if(ObEnemies* enemy = dynamic_cast<ObEnemies*> (object)){
		//exception

		if(ETurtle* etur = dynamic_cast<ETurtle*> (object)){
			if(rs.mState == LEFT || rs.mState == RIGHT || rs.mState == Top){
				if(etur->getLevel() == 0 && etur->getVelocity().x == 0){
					return;
				}
			}else{
				mVelocity.y = 200.0f;
			}
		}

		//
		if(rs.mState == LEFT || rs.mState == RIGHT || rs.mState == Top){
			kill(false);
			return;
		}else{
			mVelocity.y = 200.0f;
		}
	}
}

void ObPlayer::update(float dt){
	mAcceleration.x = 0.0f; 

	if(isMapDone){
		if(mPos.x - farpos >= 80){
			mVelocity.x = 0.0f;
			mVelocity.y = 0.0f;
			mCurrentAction = SAYGOODBYE;
			PlaySound(sFinishMap);
		}
		calSprite(dt);
		return;
	}

	//pipe transport
	if(transportindelay > 0.0f){
		transportindelay -=dt;
		if(transportindelay<= 0.0f){
			transportindelay = 0.0f;
			getOutOfPile();
			
		}
	}

	if(transportoutdelay > 0.0f){
		transportoutdelay -=dt;
		if(transportoutdelay<= 0.0f){
			transportoutdelay = 0.0f;
			setCanInput(true);
			mNeedCollision	= true;
			mIsYGravity		= true;
			mIsXGravity		= true;
			mVelocity.x = 0.0f;
			mVelocity.y = 0.0f;
			gCamera->reset((int)mPos.x, (int)mPos.y);
		}
	}
	//

	//justhit and eat eat stuff

	if(isGoD > 0.0f){
		isGoD -= dt;
		if(isGoD<= 0.0f){
			isGoD = 0.0f;
		}
	}

	if(isJustHitted> 0.0f){
		isJustHitted -= dt;
		mNeedCollision = false;
		mIsYGravity = false;
		canInput = false;
		mVelocity.x = 0.0f;
		mVelocity.y = 0.0f;

		if(isJustHitted<= 0.0f){
			isJustHitted = 0.0f;
			mNeedCollision = true;
			mIsYGravity = true;
			canInput = true;
			setStatus(mStatus,true);
			setStatus(mStatus);
		}
		calSprite(dt);
		return;
	}

	if(isJustAte> 0.0f){
		isJustAte -= dt;
		mNeedCollision = false;
		mIsYGravity = false;
		canInput = false;
		mVelocity.x = 0.0f;
		mVelocity.y = 0.0f;
		if(isJustAte<= 0.0f){
			isJustAte = 0.0f;
			mNeedCollision = true;
			mIsYGravity = true;
			canInput = true;
			setStatus(mStatus,true);
			setStatus(mStatus);
		}
		calSprite(dt);
		return;
	}

	//camera update
	if(mCurrentAction != DIE) {
		if(mIsJump){
			gCamera->setPos((int)mPos.x,(int)mPos.y,false);
		}else{
			gCamera->setPos((int)mPos.x,(int)mPos.y,true);
		}
	}


	if(mCurrentAction == DIE){
		if(mNeedCollision){
			delaycount = 2.0f;
			mVelocity.y = 300.0f;
			mNeedCollision = false;
			mVelocity.x = 0.0f;
		}
		delaycount-=dt;
		if(delaycount <= 0.0f){
			mNeedDispose = true;
			delaycount = 0.0f;
		}
		calSprite(dt);
		return;
	}

	if(gInput->keyDown(DIK_DOWNARROW) && mStatus != SMALL && canInput){
		if(mCurrentAction!= LAYDOWN){
			mCurrentAction = LAYDOWN;
			mHeight = 16.0f;
			mCenter	= D3DXVECTOR3(mWidth/2, mHeight/2, 0.0f);
		}
		calSprite(dt);
		return;
	}else{
		if(mHeight == 16.0f && mStatus != SMALL){
			mHeight = 32.0f;
			mPos.y += 16.0f;
			mCenter	= D3DXVECTOR3(mWidth/2, mHeight/2, 0.0f);
		}
	}

	if(gInput->keyDown(DIK_LEFTARROW) && canInput){
		mRightFaced = LEFT;
		if(canRun == false){
			if(requestedKey != DIK_LEFTARROW) canInput = true;
			mVelocity.x = 0.0f;
			mAcceleration.x = 0.0f;
			mCurrentAction = DONOTHING;
		}else{
			mAcceleration.x = -PLAYER_NORMAL_X_ACCEL;
			if(mIsJump == false){
				mCurrentAction = RUN;
			}

			if(gInput->keyDown(DIK_LSHIFT)){
				MAX_VELOCITYX	= PLAYER_FAST_SPD;
				mAcceleration.x = -PLAYER_FAST_X_ACCEL;
				mCurrentAction = RUNFASTER;
			}else{
				MAX_VELOCITYX	= PLAYER_NORMAL_SPD;
			}
		}
		
	}else{
		if(requestedKey == DIK_LEFTARROW){
			canRun = true;
		}
	}

	if(gInput->keyDown(DIK_RIGHTARROW) && canInput){
		mRightFaced = RIGHT;
		if(canRun == false){
			if(requestedKey != DIK_RIGHTARROW) canRun = true;
			mAcceleration.x = 0.0f;
			mVelocity.x = 0.0f;
			mCurrentAction = DONOTHING;
		}else{
			mAcceleration.x = PLAYER_NORMAL_X_ACCEL;
			if(mIsJump == false){
				mCurrentAction = RUN;
			}

			if(gInput->keyDown(DIK_LSHIFT)){
				MAX_VELOCITYX	= PLAYER_FAST_SPD;
				mAcceleration.x = PLAYER_FAST_X_ACCEL;
				mCurrentAction = RUNFASTER;
			}else{
				MAX_VELOCITYX	= PLAYER_NORMAL_SPD;
			}
		}
		
	}else{
		if(requestedKey == DIK_RIGHTARROW){
			canRun = true;
		}
	}

	if(gInput->keyDown(DIK_LEFTARROW) == false && gInput->keyDown(DIK_UPARROW) == false && gInput->keyDown(DIK_DOWNARROW) == false && gInput->keyDown(DIK_RIGHTARROW) == false){
		if(-70.0f < mVelocity.x && mVelocity.x < 70.0f){
			mVelocity.x = 0;
			if(mIsJump == false){
				mCurrentAction = DONOTHING;
			}
		}
	}

	if(gInput->keyDown(DIK_UPARROW) && canInput){
		if(mIsJump == false && jumpcount == 0.0f) {
			PlaySound(sJump);
			mVelocity.y = PLAYER_JUMP_SPD;
			mIsJump = true;
			mCurrentAction = JUMP;
		}

		jumpcount+=dt;
		if(jumpcount<0.2f && mIsJump == true){
			mVelocity.y = PLAYER_JUMP_SPD;
			mCurrentAction = JUMP;
		}

	}else{
		jumpcount = 0.3f;
	}

	if(shootcount > 0.0f){
		shootcount-=dt;
		if(shootcount<= 0.0f){
			shootcount = 0.0f;
		}
	}
	if(gInput->keyDown(DIK_SPACE ) && mStatus == FLOWER && canInput){
		if(shootcount == 0.0f){
			PlaySound(sShoot);
			bool isleft = (mRightFaced == LEFT)?true:false;
			gMapScene->mNewObject.push_back(new ObBullet(mBulletTex,mPos.x,mPos.y,isleft));
			shootcount = 0.6f;
		}
	}

	//save stat = [IsRightFace][PLAYERSTATUS][LIFE][Score]
	std::string temp = std::to_string((int)mRightFaced) + std::to_string((int)mStatus) + std::to_string(mLife) + std::to_string(mScore);
	mInfo = std::atoi(temp.c_str());
	calSprite(dt);
}

void ObPlayer::calSprite(float dt){
	//cal sprite :3
	if(delayupdate > 0.0f){
		delayupdate -= dt;
		if(delayupdate<=0.0f){
			delayupdate = 0.0f;
		}else{
			return;
		}
	}

	switch (mCurrentAction)
	{
	case DONOTHING:
		mCurrentSprite	= 0;
		mSpritePos.x	= 10.0f;
		mSpritePos.y	= 10.0f;
		break;

	case RUN:
		mSpritePos.x = 10.0f;
		mSpritePos.y = 10.0f;
		count+=dt;
		if(count >= 0.1f){
			if(isBack){
				mCurrentSprite--;
			}else{
				mCurrentSprite++;
			}
			
			if(mCurrentSprite >=2){
				isBack = true;
				mCurrentSprite = 2;
			}
			if(mCurrentSprite <=0){
				isBack = false;
				mCurrentSprite = 0;
			}	
			count = 0.0f;
		}
		mSpritePos.x = mSpritePos.x + 20*mCurrentSprite;
		break;

	case RUNFASTER:
		mSpritePos.x = 10.0f;
		mSpritePos.y = 10.0f;
		count+=dt;
		if(count >= 0.05f){
			if(isBack){
				mCurrentSprite--;
			}else{
				mCurrentSprite++;
			}
			
			if(mCurrentSprite >=2){
				isBack = true;
				mCurrentSprite = 2;
			}
			if(mCurrentSprite <=0){
				isBack = false;
				mCurrentSprite = 0;
			}	
			count = 0.0f;
		}
		mSpritePos.x = mSpritePos.x + 20*mCurrentSprite;
		break;

	case SHOOT:
		mCurrentSprite = 0;
		mSpritePos.x = 150.0f;
		mSpritePos.y = 10.0f;
		
		break;
	case JUMP:
		mCurrentSprite = 0;
		mSpritePos.x = 70.0f;
		mSpritePos.y = 10.0f;
		break;

	case GRASP:
		break;

	case DIE:
		mCurrentSprite = 0;
		mSpritePos.x = 50.0f;
		mSpritePos.y = 30.0f;
		break;
	case LAYDOWN:
		mCurrentSprite = 0;
		mSpritePos.x = 70.0f;
		mSpritePos.y = 30.0f;
		break;

	case SWIM:
		mSpritePos.x = 90.0f;
		mSpritePos.y = 30.0f;
		count += dt;
		if(count >= 0.10f){
			mCurrentSprite++;
			if(mCurrentSprite > 2) mCurrentSprite = 0;
			count = 0.0f;
		}
		mSpritePos.x += 20*mCurrentSprite;
		break;
	case SAYGOODBYE:
		mCurrentSprite = 0;
		mSpritePos.x = 10.0f;
		mSpritePos.y = 30.0f;
		break;
	default:
		mCurrentSprite = 0;
		mSpritePos.x = 10.0f;
		mSpritePos.y = 10.0f;
		break;
	}

	if(isJustHitted>0.0f){
		delayupdate = 0.1f;
		switch (mStatus)
		{
		case SMALL:
			if(mFakeStatus == SMALL){
				setStatus(BIG,true);
			}else{
				setStatus(SMALL,true);
			}
			break;
		case BIG:
			if(mFakeStatus == BIG){
				setStatus(FLOWER,true);
			}else{
				setStatus(BIG,true);
			}
			break;
		case FLOWER:
			break;
		default:
			break;
		}
	}

	if(isJustAte>0.0f){
		delayupdate = 0.1f;
		switch (mStatus)
		{
		case SMALL:
			break;
		case BIG:
			if(mFakeStatus == BIG){
				setStatus(SMALL,true);
			}else{
				setStatus(BIG,true);
			}
			break;
		case FLOWER:
			if(mFakeStatus == BIG){
				setStatus(FLOWER,true);
			}else{
				setStatus(BIG,true);
			}
			break;
		default:
			break;
		}
	}

	//sprite maps to status
	switch (mStatus)
	{
	case SMALL:
		break;
	case BIG:
		if(mSpritePos.y == 10.0f){
			mSpritePos.y += 50.0f;
		}else{
			mSpritePos.y += 70.0f;
		}
		break;
	case FLOWER:
		if(mSpritePos.y == 10.0f){
			mSpritePos.y += 130.0f;
		}else{
			mSpritePos.y += 150.0f;
		}
		break;
	default:
		break;
	}
}

void ObPlayer::render(ID3DXSprite* mSprite){
	if(mID == 0) return;
	if(mTex == 0) return;
	if(mCurrentSprite == -1) return;
	if(mNeedDispose) return;
	
	HR(gDevice->SetRenderState(D3DRS_ALPHATESTENABLE,true));
	D3DXMATRIX S;
	if(mRightFaced == RIGHT){
		D3DXMatrixScaling(&S,1.0f,-1.0f,1.0f);
	}else{
		D3DXMatrixScaling(&S,-1.0f,-1.0f,1.0f);
	}
	D3DXMATRIX R;
	D3DXMatrixRotationZ(&R, mRotation);
	D3DXMATRIX T;
	D3DXMatrixTranslation(&T,mPos.x - gCamera->getPos().x, mPos.y - gCamera->getPos().y, 0);
	mSprite->SetTransform(&(S*R*T));
	RECT rect = calRenderRECT(mSpritePos,mWidth,mHeight);
	mSprite->Draw(mTex,&rect,&mCenter,0,D3DCOLOR_XRGB(255, 255, 255));
	mSprite->Flush();
	HR(gDevice->SetRenderState(D3DRS_ALPHATESTENABLE,false));
}

bool ObPlayer::loadTexture(){
	if(mTex == 0){
		D3DXCreateTextureFromFileEx(gDevice,"Sprites/Mario.png",
			D3DX_DEFAULT_NONPOW2,
			D3DX_DEFAULT_NONPOW2,
			0,
			0,
			D3DFMT_UNKNOWN,
			D3DPOOL_MANAGED,
			D3DX_DEFAULT,
			D3DX_DEFAULT,
			D3DCOLOR_XRGB(0,0,0),
			NULL,
			NULL,
			&mTex);
	}else{
		return false;
	}

	if(mBulletTex == 0){
		D3DXCreateTextureFromFileEx(gDevice,"Sprites/Bullet.png",
			D3DX_DEFAULT_NONPOW2,
			D3DX_DEFAULT_NONPOW2,
			0,
			0,
			D3DFMT_UNKNOWN,
			D3DPOOL_MANAGED,
			D3DX_DEFAULT,
			D3DX_DEFAULT,
			D3DCOLOR_XRGB(0,0,0),
			NULL,
			NULL,
			&mBulletTex);
	}else{
		return false;
	}

	sDye = LoadSound("Sounds\\Dying.wav");
	sShoot = LoadSound("Sounds\\Shoot.wav");
	sGetCoin = LoadSound("Sounds\\GetCoin.wav");
	sExtraLife = LoadSound("Sounds\\ExtraLife.wav");
	sFinishMap = LoadSound("Sounds\\FinishMap.wav");
	sJump = LoadSound("Sounds\\Jump.wav");
	sLVUp = LoadSound("Sounds\\LevelUp.wav");
	return true;
}

bool ObPlayer::releaseTexture(){
	if(mTex != 0){
		ReleaseCOM(mTex);
	}

	if(mBulletTex != 0){
		ReleaseCOM(mBulletTex);
	}

	if( sDye != NULL){
		delete sDye;
	}

	if( sShoot != NULL){
		delete sShoot;
	}

	if( sGetCoin != NULL){
		delete sGetCoin;
	}

	if( sExtraLife != NULL){
		delete sExtraLife;
	}

	if( sFinishMap != NULL){
		delete sFinishMap;
	}

	if( sJump != NULL){
		delete sJump;
	}

	if( sLVUp != NULL){
		delete sLVUp;
	}

	return true;
}

int	ObPlayer::getLife(){
	return mLife;
}

void ObPlayer::setLife(int life){
	if(life >=5) mLife = 5;
	else{
		mLife = life;
	}
	
}

int	ObPlayer::getScore(){
	return mScore;
}
void ObPlayer::setScore(int nscore){
	mScore = nscore;
}

bool ObPlayer::getIsGoD(){
	if(isGoD > 0.0f){
		return true;
	}else{
		return false;
	}
}

Action ObPlayer::getCurrentAction(){
	return mCurrentAction;
}

PLAYERSTATE ObPlayer::getStatus(){
	return mStatus;
}

void ObPlayer::setStatus(PLAYERSTATE nstatus, bool fake){
	if(fake == false){
		if(mStatus == SMALL && (nstatus == BIG || nstatus == FLOWER)){
			mPos.y +=8.0f;
		}
		if(nstatus == SMALL && (mStatus == BIG || mStatus == FLOWER)){
			mPos.y -=8.0f;
		}
		mStatus = nstatus;
	}else{
		if(mFakeStatus == SMALL && (nstatus == BIG || nstatus == FLOWER)){
			mPos.y +=8.0f;
		}
		if(nstatus == SMALL && (mFakeStatus == BIG || mFakeStatus == FLOWER)){
			mPos.y -=8.0f;
		}
		mFakeStatus = nstatus;
	}
	switch (mStatus)
	{
	case SMALL:
		mWidth	= 16.0f;
		mHeight = 16.0f;
		return;
	case BIG:
		mWidth	= 16.0f;
		mHeight = 32.0f;
		break;
	case FLOWER:
		mWidth	= 16.0f;
		mHeight = 32.0f;
		break;
	default:
		mWidth	= 16.0f;
		mHeight = 16.0f;
		break;
	}
	mCenter = D3DXVECTOR3(mWidth/2, mHeight/2, 0.0f);
}




